@extends('admin.base')


@section('content')
<!-- Content Header (Page header) -->
    <section class="content-header">
          <h1>
            商品信息管理表

          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">商品管理</a></li>
            
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-md-12">
              <div class="box">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-th"></i> 商品信息管理</h3>
                  &nbsp; <button class="btn btn-sm btn-primary" onclick="window.location='{{URL('admin/goods/create')}}'">添加商品</button>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table class="table table-bordered">
                    <tr>
                      <th style="width:50px">ID号</th>
                      <th>商品类别</th>
                      <th>商品名称</th>
                      <th>商品图片</th>
                      <th>商品信息</th>
                      <th>商品价格</th>
                      <th>商品状态</th>
                      <th>添加时间</th>
                      <th style="width: 100px">操作</th>
                    </tr>
                    @foreach($list as $vo)
                        <tr>
                            <td>{{ $vo->id }}</td>
                            @foreach($data as $v)
                            @if($v->cate_id == $vo->cate_id)
                                <td>{{$v->cate_name}}</td>
                            @endif
                            @endforeach
                            <td>{{ $vo->goods_title}}</td>
                            <td><img width = "100px" src="{{URL($vo->goods_img)}}"</td>
                            <td>{{ $vo->goods_info}}</td>
                            <td>{{ $vo->goods_price}}</td>
                            <td>{{ $arr[$vo->goods_status]}}</td>
                            <td>{{ $vo->created_at}}</td>
                            <td><a href="javascript:;" onclick="doDel({{$vo->id}})"><button class="btn btn-xs btn-danger">删除</button></a>
                                <a href="{{url('admin/goods/'.$vo->id.'/edit')}}"><button class="btn btn-xs btn-primary" >编辑</button></a></td>

                        </tr>
                    @endforeach
                    
                  </table>
                    <div class="page_list">
                        <?php
                        $key = isset($keys) ? $keys : '';
                        ?>
                        {{ $list->appends(['keywords' => $key  ])->links() }}
                    </div>
                </div><!-- /.box-body -->

              </div><!-- /.box -->

            </div><!-- /.col --> 
          </div><!-- /.row -->
        </section><!-- /.content -->
        
    @endsection
    
    
    <script type="text/javascript">
        
		
		function doDel(id){

      

      
      //询问框
      layer.confirm('是否确认删除？', {
          btn: ['确定','取消'] //按钮
      }, function(){
			     $.post("{{url('admin/goods')}}/"+id,{'_method':'delete','_token':"{{csrf_token()}}"},function(data){
              if(data.status == 0){
                  location.href = location.href;
                  layer.msg(data.msg, {icon: 6});
              }else{
                  location.href = location.href;
                  layer.msg(data.msg, {icon: 5});
              }
            });

            }, function(){

      });



		}
		

       
    </script>
